var t = getApp();

Page({
    data: {
        type: "",
        record_title: "",
        activeName: "-1",
        title_api: "",
        list_api: "",
        rewardsData: {},
        recordsList: [],
        isLoadMore: !0,
        page: 1,
        total_page: 0
    },
    onLoad: function(t) {
        this.setData({
            type: t.name,
            record_title: t.reward_name
        }), this.data.record_title && wx.setNavigationBarTitle({
            title: this.data.record_title
        }), this.initData(this.data.type), this.getData(), this.getRecord_title();
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    initData: function(t) {
        switch (t) {
          case "DirectReward":
            this.setData({
                title_api: "plugin.nominate.frontend.prize-home.nominate-prize-home",
                list_api: "plugin.nominate.frontend.prize-home.nominate-prize-list"
            });
            break;

          case "PoorPrize":
            this.setData({
                title_api: "plugin.nominate.frontend.prize-home.nominate-poor-prize-home",
                list_api: "plugin.nominate.frontend.prize-home.nominate-poor-prize-list"
            });
            break;

          case "TeamAward":
            this.setData({
                title_api: "plugin.nominate.frontend.prize-home.team-prize-home",
                list_api: "plugin.nominate.frontend.prize-home.team-prize-list"
            });
            break;

          case "TeamPerformance":
            this.setData({
                title_api: "plugin.nominate.frontend.prize-home.team-manage-prize-home",
                list_api: "plugin.nominate.frontend.prize-home.team-manage-prize-list"
            });
        }
    },
    getRecord_title: function() {
        var e = this, a = t.getNetAddresss(this.data.title_api);
        t._getNetWork({
            url: a,
            success: function(t) {
                var a = t.data;
                1 === a.result ? e.setData({
                    rewardsData: a.data
                }) : wx.showToast({
                    title: a.msg,
                    icon: "none"
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getData: function() {
        var e = this;
        this.setData({
            recordsList: [],
            isLoadMore: !1,
            page: 1
        });
        var a = t.getNetAddresss(this.data.list_api);
        a += "&status=" + this.data.activeName + "&page=" + this.data.page, t._getNetWork({
            url: a,
            success: function(t) {
                var a = t.data;
                1 === a.result ? (e.setData({
                    isLoadMore: !0,
                    total_page: a.data.last_page
                }), e.data.total_page || e.setData({
                    total_page: 0
                }), e.setData({
                    recordsList: a.data.list.data
                })) : wx.showToast({
                    title: a.msg,
                    icon: "none"
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    handleClick: function(t) {
        0 == t.detail.index ? this.setData({
            activeName: "-1"
        }) : 1 == t.detail.index ? this.setData({
            activeName: "1"
        }) : 2 == t.detail.index ? this.setData({
            activeName: "0"
        }) : 3 == t.detail.index && this.setData({
            activeName: "2"
        }), this.getData();
    }
});